package com.feeyo.groundservice.ws.common

/**
 *作者：QLH on 2019-06-14
 *描述：websocket参数设置
 */
class WebSocketSetting {

    //WebSocket 连接地址
    private var connectUrl: String? = null

    //设置心跳间隔时间(单位秒)
    private var connectionLostTimeout = CONNECTION_LOST_TIMEOUT

    //设置readTimeout
    private var readTimeout = READ_TIMEOUT

    //设置writeTimeout
    private var writeTimeout = WRITE_TIMEOUT

    //设置connectTimeout
    private var connectTimeout = CONNECT_TIMEOUT

    //最大重连次数
    private var maxReconnectTimes = MAX_RECONNECT_TIMES

    //需要绑定的host域名
    private var host = ""

    //端口
    private var port:Int = 0

    //心跳间隔
    private var pingInterval = 0L

    //是否忽略证书
    private var notSSL: Boolean = false

    /**
     * 获取 WebSocket 链接地址
     */
    fun getConnectUrl() = connectUrl

    /**
     * 设置 WebSocket 连接地址，必须设置项。
     */
    fun setConnectUrl(connectUrl: String) {
        this.connectUrl = connectUrl
    }

    /**
     * 获取心跳间隔时间
     */
    fun getConnectionLostTimeout() = connectionLostTimeout

    /**
     * 设置心跳间隔时间，单位为秒；
     * 默认为30秒。
     */
    fun setConnectionLostTimeout(connectionLostTimeout: Long) {
        this.connectionLostTimeout = connectionLostTimeout
    }

    /**设置readTimeout，单位秒
     * 默认5秒**/
    fun setReadTimeout(time: Long) {
        readTimeout = time
    }

    fun getReadTimeout() = readTimeout

    /**设置writeTimeout，单位秒
     * 默认5秒**/
    fun setWriteTimeout(time: Long) {
        writeTimeout = time
    }

    fun getWriteTimeout() = writeTimeout

    /**设置connectTimeout，单位秒
     * 默认5秒
     * **/
    fun setConnectTimeout(time: Long) {
        connectTimeout = time
    }

    fun getConnectTimeout() = connectTimeout

    /**设置最大重连次数，默认15次**/
    fun setMaxReconnectTimes(times: Int) {
        maxReconnectTimes = times
    }

    fun getMaxReconnectTimes() = maxReconnectTimes

    fun setHost(host: String) {
        this.host = host
    }

    fun getHost(): String = host

    fun setPort(port:Int){
        this.port = port
    }

    fun getPort():Int = port

    fun setPingInterval(time:Long){
        this.pingInterval = time
    }

    fun getPingInterval() = pingInterval

    fun setNotSSL(notSSL: Boolean) {
        this.notSSL = notSSL
    }

    fun isNotSSL(): Boolean = notSSL

}